﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RoleList.ascx.cs" Inherits="Components_Member_ListRole" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods="true" >
</asp:ScriptManager>
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Sunset" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function showForm(url) {
            window.radopen(url, "RadWindow1");
            return false;
        }
        function OnClientClose(oWnd, args, code, name) {
            var arg = args.get_argument();
            if (arg == '' || arg == null) {
            }
            else {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(arg);
            }
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadWindowManager ID="RadWindowManager1" VisibleStatusbar="false" runat="server"
    Skin="Sunset" EnableShadow="true" DestroyOnClose="True" EnableAriaSupport="True">
    <Windows>
        <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="RoleList.aspx" OnClientClose="OnClientClose">
        </telerik:RadWindow>
    </Windows>
    <Windows>
        <telerik:RadWindow ID="RadWindow2" runat="server" Height="500px" OnClientClose="OnClientClose"
            Width="700px">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

    <asp:UpdatePanel ID="u" runat="server">
        <ContentTemplate>
            <div class="form-horizontal wrapper-center clearfix">
                <div class="form-group col-md-6">
                    <div class="form-group">
                        <label class="col-md-4 control-label">
                            Nhóm quyền cấp trên</label>
                        <div class="col-md-8">
                            <telerik:RadComboBox ID="cboParentID" runat="server" AutoPostBack="true" OnSelectedIndexChanged="cboParentID_SelectedIndexChanged"
                                TabIndex="1" CssClass="col-imp-10" />
                        </div>
                    </div>
                </div>
                <div class="form-group col-md-6">
                    <div class="form-group">
                        <label class="col-md-4 control-label">
                            Tên nhóm quyền</label>
                        <div class="col-md-8">
                            <telerik:RadTextBox ID="txtRoleName" runat="server" OnTextChanged="txtRoleName_TextChanged"
                                TabIndex="2" CssClass="col-imp-10" />
                        </div>
                    </div>
                </div>
            </div>

            <div class="set-btns text-center">
                <asp:Button ID="btnSearch" runat="server" Text="Tìm" OnClick="btnSearch_Click" TabIndex="3"
                    CssClass="btn btn-sm btn-primary" />
                <asp:Button CssClass="btn btn-sm btn-primary" ID="btnClear" runat="server" Text="Nhập Lại"
                    WOnClick="btnClear_Click" OnClick="btnClear_Click1" TabIndex="4" Visible="False" />
                <asp:Button CssClass="btn btn-sm btn-primary" ID="btnNew" runat="server" Text="Thêm mới"
                    OnClick="btnNew_Click" TabIndex="5" />
                <br />
                <asp:Label ID="lblResult" runat="server" Text="" ForeColor="Red" />
            </div>
          
            <div class="form-group text-right">
                <asp:Button ID="btnDelete" runat="server" OnClientClick="return ConfirmOnDelete('Bạn chắc muốn xóa không? Nếu những Nhóm quyền này đang được sử dụng để phân quyền cho các user, sẽ xoá các phân quyền liên quan đến Nhóm quyền này.');"
                    OnClick="btnDelSelection_Click" Text="Xoá" CssClass="btn btn-sm btn-warning"
                    TabIndex="6" />
            </div>
            <div class="row">
                <telerik:RadGrid ID="grvData" runat="server" CellSpacing="0" GridLines="None" AutoGenerateColumns="False"
                    HeaderStyle-HorizontalAlign="Center" OnItemCommand="grvData_ItemCommand" AllowMultiRowSelection="True"
                    OnPageIndexChanged="grvData_PageIndexChanged1" OnPageSizeChanged="grvData_PageSizeChanged1"
                    HeaderStyle-BorderStyle="None" CssClass="table table-bordered">
                    <MasterTableView ShowHeader="true" AllowPaging="True" PageSize="50" NoMasterRecordsText="Không có dữ liệu."
                        ShowGroupFooter="true">
                        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridTemplateColumn HeaderText="STT" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center"
                                HeaderStyle-Width="20px">
                                <ItemTemplate>
                                    <%# Container.ItemIndex + 1 %></ItemTemplate>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="ID" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                FilterControlAltText="Filter RoleId column" HeaderText="Mã nhóm quyền" UniqueName="ID"
                                Display="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="RoleName" HeaderStyle-HorizontalAlign="Center"
                                FilterControlAltText="Filter RoleName column" HeaderText="Tên nhóm quyền" UniqueName="RoleName">
                                <HeaderStyle HorizontalAlign="Left" Width="300px" />
                                <ItemStyle HorizontalAlign="Left" />
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Remark" HeaderStyle-HorizontalAlign="Center"
                                ItemStyle-HorizontalAlign="Left" FilterControlAltText="Filter Remark column"
                                HeaderText="Ghi chú" UniqueName="Remark">
                                <HeaderStyle HorizontalAlign="Left" Width="300px"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Left"></ItemStyle>
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn DataField="IsSystemRole" SortExpression="IsSystemRole"
                                UniqueName="IsSystemRole" HeaderText="Hệ thống" ItemStyle-HorizontalAlign="Center"
                                HeaderStyle-HorizontalAlign="Center" Display="false">
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" Enabled="false" AutoPostBack="true" Checked='<%# Convert.ToBoolean(Eval("IsSystemRole")) %>'
                                        runat="server" />
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter column column"
                                HeaderText="Trạng thái" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                UniqueName="column" Display="false">
                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridBoundColumn>
                            
                            <telerik:GridTemplateColumn HeaderText="Sửa" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Button ID="lnkEditDel" CssClass="btnDelete" CommandArgument='<%# Eval("ID") %>'
                                        CommandName="EditDelItem" runat="server"></asp:Button>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Center" Width="10px" />
                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                            </telerik:GridTemplateColumn>
                            <telerik:GridClientSelectColumn FilterControlAltText="Filter column1 column" UniqueName="checkbox"
                                HeaderText="Chọn">
                                <HeaderStyle HorizontalAlign="Center" Width="10px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridClientSelectColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <ClientSettings>
                        <Selecting AllowRowSelect="true" />
                    </ClientSettings>
                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>
                </telerik:RadGrid>
            </div>
        </ContentTemplate>
        <%--<Triggers>
        <asp:PostBackTrigger ControlID="grvData" />
    </Triggers>--%>
    </asp:UpdatePanel>
    <%-- </ContentTemplate>
</asp:UpdatePanel>--%>
    <div class="progressbar">
        <asp:UpdateProgress ID="up" runat="server" AssociatedUpdatePanelID="u">
            <ProgressTemplate>
                <img src="Template/Images/ajax-progress-bar.gif" alt="progressbar" />
            </ProgressTemplate>
        </asp:UpdateProgress>
    </div>
    <script type="text/javascript">
        function DelRole(id) {
            PageMethods.DelAllRole(id, OnSuccess);
            alert(id);
        }
        function OnSuccess(response, userContext, methodName) {
            alert(response);
        }
    
    </script>